import Mock from 'mockjs'
import config from '@/config'

const baseUrl = config.baseUrl

// 导入CMS模块的mock数据
import * as cmsApi from './cms'

// 导入商品模块的mock数据
import './pet/product.js'

// 设置全局延迟，模拟网络请求耗时
Mock.setup({
  timeout: '300-600'
})

// CMS模块API mock
// 文章相关
Mock.mock(new RegExp(baseUrl + '/cms/archives/index'), 'get', cmsApi.archives.getArchivesList)
Mock.mock(new RegExp(baseUrl + '/cms/archives/detail'), 'post', cmsApi.archives.getArchivesDetail)
Mock.mock(new RegExp(baseUrl + '/cms/archives/vote'), 'post', cmsApi.archives.voteArchives)
Mock.mock(new RegExp(baseUrl + '/cms/archives/order'), 'post', cmsApi.archives.submitOrder)
Mock.mock(new RegExp(baseUrl + '/cms/archives/get_channel'), 'get', cmsApi.archives.getChannel)
Mock.mock(new RegExp(baseUrl + '/cms/archives/get_channel_fields'), 'get', cmsApi.archives.getChannelFields)
Mock.mock(new RegExp(baseUrl + '/cms/archives/archives_post'), 'post', cmsApi.archives.postArchives)
Mock.mock(new RegExp(baseUrl + '/cms/archives/my'), 'get', cmsApi.archives.getMyArchives)
Mock.mock(new RegExp(baseUrl + '/cms/archives/delete'), 'post', cmsApi.archives.deleteArchives)

// 用户相关
Mock.mock(new RegExp(baseUrl + '/cms/user/index'), 'get', cmsApi.user.getUserInfo)
Mock.mock(new RegExp(baseUrl + '/cms/user/profile'), 'post', cmsApi.user.updateUserProfile)
Mock.mock(new RegExp(baseUrl + '/cms/user/logout'), 'get', cmsApi.user.logout)
Mock.mock(new RegExp(baseUrl + '/cms/user/avatar'), 'post', cmsApi.user.updateAvatar)
Mock.mock(new RegExp(baseUrl + '/cms/user/userInfo'), 'post', cmsApi.user.getSpecificUserInfo)
Mock.mock(new RegExp(baseUrl + '/cms/user/signed'), 'get', cmsApi.user.getUserSigned)

// 评论相关
Mock.mock(new RegExp(baseUrl + '/cms/comment/post'), 'post', cmsApi.comment.postComment)
Mock.mock(new RegExp(baseUrl + '/cms/comment/index'), 'post', cmsApi.comment.getCommentList)
Mock.mock(new RegExp(baseUrl + '/cms/my/comment'), 'get', cmsApi.comment.getMyComment)

// 公共接口
Mock.mock(new RegExp(baseUrl + '/cms/common/init'), 'get', cmsApi.common.getConfig)
Mock.mock(new RegExp(baseUrl + '/cms/common/captcha'), 'get', cmsApi.common.getCaptcha)
Mock.mock(new RegExp(baseUrl + '/cms/common/getCategory'), 'get', cmsApi.common.getCategory)
Mock.mock(new RegExp(baseUrl + '/cms/common/selectpage'), 'get', cmsApi.common.selectPage)

// 登录相关
Mock.mock(new RegExp(baseUrl + '/cms/login/login'), 'post', cmsApi.login.login)
Mock.mock(new RegExp(baseUrl + '/cms/login/mobilelogin'), 'post', cmsApi.login.mobileLogin)
Mock.mock(new RegExp(baseUrl + '/cms/login/register'), 'post', cmsApi.login.register)
Mock.mock(new RegExp(baseUrl + '/cms/login/resetpwd'), 'post', cmsApi.login.resetPassword)
Mock.mock(new RegExp(baseUrl + '/cms/login/wxLogin'), 'post', cmsApi.login.wxLogin)
Mock.mock(new RegExp(baseUrl + '/cms/login/wechatMobileLogin'), 'post', cmsApi.login.wechatMobileLogin)
Mock.mock(new RegExp(baseUrl + '/cms/login/appLogin'), 'post', cmsApi.login.appLogin)
Mock.mock(new RegExp(baseUrl + '/cms/login/getWechatOpenid'), 'post', cmsApi.login.getWechatOpenid)
Mock.mock(new RegExp(baseUrl + '/cms/login/getWechatMobile'), 'post', cmsApi.login.getWechatMobile)

// 收藏相关
Mock.mock(new RegExp(baseUrl + '/cms/collection/index'), 'get', cmsApi.collection.getCollectionList)
Mock.mock(new RegExp(baseUrl + '/cms/collection/create'), 'post', cmsApi.collection.addCollection)
Mock.mock(new RegExp(baseUrl + '/cms/collection/delete'), 'post', cmsApi.collection.deleteCollection)

// 专题相关
Mock.mock(new RegExp(baseUrl + '/cms/special/special'), 'get', cmsApi.special.getSpecialList)
Mock.mock(new RegExp(baseUrl + '/cms/special/index'), 'get', cmsApi.special.getSpecialDetail)

// 单页相关
Mock.mock(new RegExp(baseUrl + '/cms/page/detail'), 'get', cmsApi.page.getPageDetail)

// 搜索相关
Mock.mock(new RegExp(baseUrl + '/cms/search/index'), 'get', cmsApi.search.search)

// 标签相关
Mock.mock(new RegExp(baseUrl + '/cms/tag/index'), 'get', cmsApi.tag.getTagList)

// 自定义表单相关
Mock.mock(new RegExp(baseUrl + '/cms/diyform/index'), 'get', cmsApi.diyform.getFormField)
Mock.mock(new RegExp(baseUrl + '/cms/diyform/postForm'), 'post', cmsApi.diyform.postForm)
Mock.mock(new RegExp(baseUrl + '/cms/diyform/formList'), 'get', cmsApi.diyform.getFormList)
Mock.mock(new RegExp(baseUrl + '/cms/diyform/show'), 'get', cmsApi.diyform.getFormShow)

export default Mock